package org.springcloud.wisdom.spring_02_classroom.notice.controller;

import org.springcloud.wisdom.spring_02_classroom.bean.BaseController;
import org.springcloud.wisdom.spring_02_classroom.bean.ResponseData;
import org.springcloud.wisdom.spring_02_classroom.notice.entity.Notice;
import org.springcloud.wisdom.spring_02_classroom.notice.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/notice")
public class NoticeController extends BaseController {
    @Autowired
    NoticeService noticeService;

    //发布公告
    @PostMapping("/add")
    public ResponseData<Object> addNotice(@RequestBody Notice notice){
        boolean success = noticeService.InsertNotice(notice);
        return returnObject(success?"提交成功，等待审核":"提交失败");
    }

    //查看所有公告
    @RequestMapping("/all")
    public ResponseData<Object> getPage(@RequestParam("pageNum") int pageNum,
                                         @RequestParam("pageSize") int pageSize){
        return returnObject(noticeService.getNotice(pageNum,pageSize));
    }

    /////////用户/////////////
    //查看迎新模块公告
    @RequestMapping("/freshman")
    public ResponseData<Object> getPage1(@RequestParam("pageNum") int pageNum,
                                        @RequestParam("pageSize") int pageSize){
        return returnObject(noticeService.getNotice1(pageNum,pageSize));
    }

    //查看食堂模块公告
    @RequestMapping("/canteen")
    public ResponseData<Object> getPage2(@RequestParam("pageNum") int pageNum,
                                        @RequestParam("pageSize") int pageSize){
        return returnObject(noticeService.getNotice2(pageNum,pageSize));
    }

    //查看社团模块公告
/*    @RequestMapping("/amusement")
    public ResponseData<Object> getPage3(@RequestParam("pageNum") int pageNum,
                                         @RequestParam("pageSize") int pageSize){
        return returnObject(noticeService.getNotice3(pageNum,pageSize));
    }*/

    //////////后台////////////
    //查看迎新模块公告
    @RequestMapping("/freshman2")
    public ResponseData<Object> getPage11(@RequestParam("pageNum") int pageNum,
                                         @RequestParam("pageSize") int pageSize){
        return returnObject(noticeService.getNotice11(pageNum,pageSize));
    }

    //查看食堂模块公告
    @RequestMapping("/canteen2")
    public ResponseData<Object> getPage22(@RequestParam("pageNum") int pageNum,
                                         @RequestParam("pageSize") int pageSize){
        return returnObject(noticeService.getNotice22(pageNum,pageSize));
    }

    //查看社团模块公告
 /*   @RequestMapping("/amusement2")
    public ResponseData<Object> getPage33(@RequestParam("pageNum") int pageNum,
                                         @RequestParam("pageSize") int pageSize){
        return returnObject(noticeService.getNotice33(pageNum,pageSize));
    }*/

    ////////////////社团///////////////
    //查看社团模块公告
    @RequestMapping("/amusement")
    public ResponseData<Object> getPage3(@RequestParam("pageNum") int pageNum,
                                         @RequestParam("pageSize") int pageSize){
        return returnObject(noticeService.getNotice3(pageNum,pageSize));
    }

    //查看具体社团模块公告
    @RequestMapping("/amusement22")
    public ResponseData<Object> getPage32(@RequestParam("pageNum") int pageNum,
                                          @RequestParam("pageSize") int pageSize,
                                          @RequestParam("type") int type ){
        return returnObject(noticeService.getNotice32(pageNum,pageSize,type));
    }

    //查看具体社团模块所有公告
    @RequestMapping("/amusement222")
    public ResponseData<Object> getPage322(@RequestParam("pageNum") int pageNum,
                                           @RequestParam("pageSize") int pageSize,
                                           @RequestParam("type") int type ){
        return returnObject(noticeService.getNotice322(pageNum,pageSize,type));
    }
}
